package com.estun.backroundManagementService.enums;

/**
 * 排程状态枚举类
 */
public enum WorkOrderStatusEnum {
    UNKNOWN("-1", "未知"),
    NEW("0", "新建"),
    ISSUED("1", "下达"),
    STARTED("2", "开线"),
    IN_PRODUCTION("3", "生产"),
    PAUSED("4", "暂停"),
    CANCELED("5", "取消"),
    COMPLETED("6", "完成");

    private final String code;
    private final String description;

    WorkOrderStatusEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据状态码获取枚举值
     *
     * @param code 状态码
     * @return 对应的枚举值，如果没有匹配项返回 null
     */
    public static WorkOrderStatusEnum getByCode(String code) {
        for (WorkOrderStatusEnum status : WorkOrderStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return UNKNOWN;
    }
}
